package com.green.web.controller.common;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.apache.log4j.Logger;
/**
 * 动态密码配置文件，配置中的工号，启用动态密码
 * 
 */
public class DynamicPasswordHelper {
	private static final Logger logger = Logger.getLogger(DynamicPasswordHelper.class);
	private static DynamicPasswordHelper instance = new DynamicPasswordHelper();
	private PropertiesConfiguration configuration;

	private DynamicPasswordHelper() {
		try {
			this.configuration = new PropertiesConfiguration("dynamicPassword.properties");
			this.configuration.setReloadingStrategy(new FileChangedReloadingStrategy());
		} catch (ConfigurationException e) {
			logger.error("Load dynamicPassword.properties error", e);
		}
	}

	public String getServer() {
		return this.configuration.getString("server");
	}
	
	public boolean isDynamicPasswordEnabled(String number) {
		return this.configuration.getBoolean(number, false);
	}

	public static DynamicPasswordHelper getInstance() {
		return instance;
	}
	
	
	public static void main(String[] args) {
		System.out.println(DynamicPasswordHelper.getInstance().isDynamicPasswordEnabled("002117"));
	}
}
